package android.slc.base.repository.local.sp;

import android.slc.box.db.sp.DpManager;
import cn.hutool.core.io.FileUtil;

public class FileSelectSp extends DpManager {

    private static class Holder {
        private static final FileSelectSp INSTANCE = new FileSelectSp();
    }

    public static FileSelectSp getInstance() {
        return Holder.INSTANCE;
    }

    private FileSelectSp() {
        super("file_select");
    }

    /**
     * @return
     */
    public String getPathByType(String key) {
        String pathByType = dp.getString(key, FileUtil.getUserHomePath(), true);
        if (FileUtil.exist(pathByType)) {
            return pathByType;
        }
        return FileUtil.getUserHomePath();
    }

    /**
     * @return
     */
    public void setPathByType(String type, String value) {
        dp.putValue(type, value);
    }
}
